

cc.Class({
    extends: cc.Component,

    properties: {
        propSprits: [cc.SpriteFrame]
    },

    onLoad() { },

    start() {

    },
    //碰撞回调
    onCollisionEnter: function (other, self) {
        if (other.node.group === "player") {
            other.node.getComponent("Player").playerAddHp(this.propHp, this.propScore);
            this.node.removeFromParent();
        }
    },

    // update (dt) {},
    initPropDt(propDt) {
        let propImg = propDt.img;
        this.propScore = propDt.score;
        this.propHp = propDt.hp;
        for (let img of this.propSprits) {
            if (propImg === img.name) {
                this.node.getComponent(cc.Sprite).spriteFrame = img;
                return;
            }
        }
        cc.error(`不存在${propImg}这个资源`);
    },

    propMove() {
        cc.tween(this.node)
            .by(2, { position: cc.v2(0, -cc.winSize.height - this.node.height), angle: -1080 })
            .removeSelf()
            .start()
    }
});
